let app = new Vue({
	el : "#main-container",
	data: {
		index: 1,       //个数
		getList1 : 0,
		xiala : 0,
		num : 0,       //数量
		shuoming : "", //说明
		dingdan1 : 0,
		num1 : 0,
		name1 : "",
		dingdan2 : 0,
		num2 : 0,
		name2 : "",
		dingdan3 : 0,
		num3 : 0,
		name3 : "",
		dingdan4 : 0,
		num4 : 0,
		name4 : "",
		dingdan5 : 0,
		num5 : 0,
		name5 : "",
	},
	created() {
		this.getList();
	},
	methods:{
		getList(){
			console.log(1);
			let data = new URLSearchParams;
			data.append("pageNum",1);
			data.append("pageSize",1000);
			data.append("goodsName","");
			axios({
				method : "post",
				url : "cangku/storeManagementAll",
				data : data,
				headers:{"token":localStorage.token,"url":window.location.pathname}
			}).then(response=>{
				console.log(response.data.data);
				this.getList1=response.data.data;
			})
		},
		indexSelect(event){
			this.xiala=event.target.value;
			console.log(this.xiala)
		},
		shuliang(){
			console.log(this.num);
			console.log(this.xiala);
			if(this.xiala>0 && this.num>0){
			switch(this.index){
				case 1:
					this.dingdan1=this.xiala;
					this.num1 = this.num;
					this.index++;
					let data1 = new URLSearchParams;
					data1.append("id",this.dingdan1);
					axios({
						method : "post",
						url : "cangku/selectById",
						data : data1,
						headers:{"token":localStorage.token,"url":window.location.pathname}
					}).then(response=>{
						console.log(response.data.data);
						this.name1=response.data.data;
					})
					break
				case 2:
					this.dingdan2=this.xiala;
					this.num2 = this.num;
					this.index++;
					let data2 = new URLSearchParams;
					data2.append("id",this.dingdan2);
					axios({
						method : "post",
						url : "cangku/selectById",
						data : data2,
						headers:{"token":localStorage.token,"url":window.location.pathname}
					}).then(response=>{
						console.log(response.data.data);
						this.name2=response.data.data;
					})
					break
				case 3:
					this.dingdan3=this.xiala;
					this.num3 = this.num;
					this.index++;
					let data3 = new URLSearchParams;
					data3.append("id",this.dingdan3);
					axios({
						method : "post",
						url : "cangku/selectById",
						data : data3,
						headers:{"token":localStorage.token,"url":window.location.pathname}
					}).then(response=>{
						console.log(response.data.data);
						this.name3=response.data.data;
					})
					break
				case 4:
					this.dingdan4=this.xiala;
					this.num4 = this.num;
					this.index++;
					let data4 = new URLSearchParams;
					data4.append("id",this.dingdan4);
					axios({
						method : "post",
						url : "cangku/selectById",
						data : data4,
						headers:{"token":localStorage.token,"url":window.location.pathname}
					}).then(response=>{
						console.log(response.data.data);
						this.name4=response.data.data;
					})
					break
				case 5:
					this.dingdan5=this.xiala;
					this.num5 = this.num;
					this.index++;
					let data5 = new URLSearchParams;
					data5.append("id",this.dingdan5);
					axios({
						method : "post",
						url : "cangku/selectById",
						data : data5,
						headers:{"token":localStorage.token,"url":window.location.pathname}
					}).then(response=>{
						console.log(response.data.data);
						this.name5=response.data.data;
					})
					break
				default:
					alert("一个订单只能申请五种物品");
					break
			}
			}
		},
		chongzhi(){
			this.index=1;
		},
		tijiao(){
				let data = new URLSearchParams;
			data.append("shuoming",this.shuoming);
			console.log(this.shuoming);
			data.append("bumen",1);
			data.append("bianhao",50003);
			data.append("name",50003);
			data.append("dingdan1",this.dingdan1);
			data.append("dingdan2",this.dingdan2);
			data.append("dingdan3",this.dingdan3);
			data.append("dingdan4",this.dingdan4);
			data.append("dingdan5",this.dingdan5);
			data.append("num1",this.num1);
			data.append("num2",this.num2);
			data.append("num3",this.num3);
			data.append("num4",this.num4);
			data.append("num5",this.num5);
			axios({
				url : "cangku/shenqing",
				method : "post",
				data : data,
				headers:{"token":localStorage.token,"url":window.location.pathname}
			}).then(response=>{
				if(response.data.data>0){
					alert("提交成功!");
				}else{
					alert("提交失败!");
				}
			})
		}
		
		
	}
})